package com.school.entity;

public class Student extends Person {
    private Course course;
    public Student(int id, String name) {
        super(id, name);
        this.course = null;
    }

    public void selectCourse(Course course) {
        this.course = course;
        System.out.println(getName() + "同学选了" + course.getName() + "课程");
    }

    public void dropCourse() {
        if (course != null) {
            System.out.println(getName() + "同学退了" + course.getName() + "课程");
            this.course = null;
        } else {
            System.out.println(getName() + "同学没有选任何课程，无法退课");
        }
    }

    @Override
    public void printWorksheet() {
        super.printWorksheet();
        if (course != null) {
            System.out.println("--- 学生课表 ---");
            System.out.println("课程名称：" + course.getName());
            System.out.println("上课地点：" + course.getLocation());
            System.out.println("上课时间：" + course.getTime());
            System.out.println("授课教师：" + course.getTeacher().getName());
        } else {
            System.out.println("--- 学生课表 ---");
            System.out.println(getName() + "同学还没有选课程，课表为空");
        }
    }
    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }
}